package com.hnevc.gui;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class BoxLayoutDemo extends JFrame{

	private JPanel p;
	private JButton[] btns;
	public BoxLayoutDemo(){
		super("Box Layout");
		
		p = new JPanel();
		p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
		btns = new JButton[6];
		for(int i=0;i<btns.length;i++){
			btns[i] = new JButton("按钮"+(i+1));
			p.add(btns[i]);
		}
		this.add(p);
		setSize(200,200);
		setLocation(200, 200);
		setVisible(true);
	}
	public static void main(String[] args) {
		new BoxLayoutDemo();
	}

}
